package com.kaili.basic.controller.pda.v1;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.dto.*;
import com.kaili.basic.pojo.entity.QueryCustomerVO;
import com.kaili.basic.service.BaseCustomerService;
import com.kaili.basic.version.ApiVersion;
import com.kaili.common.util.LoginDetailUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zengshuai
 * @Copyright: Copyright (c) 2017
 * @Company: 杭州凯立通信有限公司
 */
@ApiVersion(1)
@RequestMapping("/{api_version}")
@RestController("baseCustomerControllerP")
@Api(tags = "[pda]客户管理", description = "[pda]客户管理相关API")
public class BaseCustomerController {

    @Autowired
    BaseCustomerService customerService;

    ////条件查询获取客户详细信息
    @GetMapping(value = "p/baseCustomer/page")
    @ApiOperation(value = "条件查询客户详细信息",notes = "条件查询客户详细信息")
    public Page<QueryCustomerVO> queryCustomerDetails(@ModelAttribute BaseCustomerQueryDto baseCustomerQueryDto) {
        QueryCustomerVO queryCustomerVO = new QueryCustomerVO();
        queryCustomerVO.setSite(baseCustomerQueryDto.getSite());
        queryCustomerVO.setName(baseCustomerQueryDto.getName());
        queryCustomerVO.setCompanyName(baseCustomerQueryDto.getCompanyName());
        queryCustomerVO.setPage(baseCustomerQueryDto.getPage());
        queryCustomerVO.setPageSize(baseCustomerQueryDto.getPageSize());
        if(LoginDetailUtils.getSiteId()!=1)
            queryCustomerVO.setSite(LoginDetailUtils.getSiteId().longValue());
        return customerService.queryCustomerDetails(new Page<QueryCustomerVO>(queryCustomerVO.getPage(),queryCustomerVO.getPageSize()),queryCustomerVO);
    }

}
